//
//  SSSCpmpleteViewCell.m
//  SSSMerchant
//
//  Created by Darker on 2017/4/3.
//  Copyright © 2017年 xnxin. All rights reserved.
//

#import "SSSCpmpleteViewCell.h"
#import "NSDateAddition.h"
@implementation SSSCpmpleteViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self addSubViews];
    }
    return self;
}
- (void)addSubViews{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    CGFloat width = KSCREEN_Width/3;
    CGFloat height = HeigthIos6CompeteWithCurrent(20);
    
    
    self.timeLabel = [UILabel new];
    [self.contentView addSubview:self.timeLabel];
    self.timeLabel.backgroundColor = [UIColor clearColor];
    self.timeLabel.textAlignment = NSTextAlignmentCenter;
    //self.timeLabel.text = @"2017-08-35";
    self.timeLabel.textColor = [UIColor colorWithHex:@"333333"];
    self.timeLabel.font = [SSSFont systemFontOfSize:12];
    self.timeLabel.sd_layout
    .centerYEqualToView(self.contentView)
    .leftSpaceToView(self.contentView,0)
    .heightIs(height)
    .widthIs(width);
    
    
    //金额
    self.moneyLabel = [UILabel new];
    [self.contentView addSubview:self.moneyLabel];
    self.moneyLabel.backgroundColor = [UIColor clearColor];
    self.moneyLabel.textAlignment = NSTextAlignmentCenter;
    //self.moneyLabel.text = @"￥305";
    self.moneyLabel.textColor = [UIColor colorWithHex:@"333333"];
    self.moneyLabel.font = [SSSFont systemFontOfSize:14];
    self.moneyLabel.sd_layout
    .centerYEqualToView(self.contentView)
    .leftSpaceToView(self.timeLabel,0)
    .heightIs(height)
    .widthIs(width);
    
    //让利金额
    self.discountNuLabel = [UILabel new];
    [self.contentView addSubview:self.discountNuLabel];
    self.discountNuLabel.backgroundColor = [UIColor clearColor];
    self.discountNuLabel.textAlignment = NSTextAlignmentCenter;
    //self.discountNuLabel.text = @"￥55";
    self.discountNuLabel.textColor = [UIColor colorWithHex:@"333333"];
    self.discountNuLabel.font = [SSSFont systemFontOfSize:14];
    self.discountNuLabel.sd_layout
    .centerYEqualToView(self.contentView)
    .leftSpaceToView(self.moneyLabel,0)
    .heightIs(height)
    .widthIs(width);
    
    //横线
    UIView *lineView = [UIView new];
    lineView.backgroundColor = [UIColor colorWithHex:@"E6E6E6"];
    [self.contentView addSubview:lineView];
    lineView.sd_layout
    .leftSpaceToView(self.contentView,WidthIos6CompeteWithCurrent(16))
    .rightSpaceToView(self.contentView,WidthIos6CompeteWithCurrent(16))
    .bottomSpaceToView(self.contentView,0)
    .heightIs(0.5);
    
    
}
- (void)setModel:(SSSCompleteModel *)model{
    
    _model = model;
    if (model.createTime.length<=0) {
        
        self.timeLabel.text = @"";
        
    }else{
        
        NSString *subStr = [model.createTime substringWithRange:NSMakeRange(0,model.createTime.length - 3)];
        self.timeLabel.text = [NSString timeDateStrFromTimeStamp:subStr];
        
    }

    self.moneyLabel.text = model.money;
    self.discountNuLabel.text = model.rangli;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
